const app = getApp()
// 上传图片
export function uploadImage(files) {
  files.forEach(file => {
    wx.showLoading({
      title: '上传中...',
    })
    wx.uploadFile({
      url: app.globalData.apiUrl + '/api/sys/file/upLoadPic',
      filePath: file.url,
      name: 'file',
      formData: {
        user: 'test'
      },
      success: (res) => {
        let data = JSON.parse(res.data)
        // 上传完成需要更新 fileList
        const fileList = this.data.fileList;
        fileList.push({
          ...file,
          url: data.data
        });
        this.setData({
          fileList
        });
      },
      complete: ()=>{
        wx.hideLoading()
      }
    });
  })
}